<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <script type="text/javascript " src="static/js/jquery-1.11.1-min.js"></script>
    <script type="text/javascript" src="static/bootstrap/js/bootstrap.min.js"></script>
    <link href="static/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    <style type="text/css">
        .content{
            margin-top:20px ;
        }
        .color{
            background-color: #ffffff;
        }
        h3 {
            text-align: center;
        }

        #search {
            float: left;
            margin: 10px;
        }

        #search div {
            margin-right: 5px;
        }

        #add_del {
            float: right;
            margin: 10px;
        }

        #add_del a {
            margin-left: 5px;
        }

        td, th {
            text-align: center;
        }
    </style>
</head>
<script type="text/javascript">
    $(function () {
        $.ajax({
            url: "admin/getTopics.do",
        })
        if(!window.name){
            window.name = 'test';
            window.location.reload();
        }
        // 注销
        $(".logoutBtn").click(function (){
            $.ajax({
                url:"admin/logout.do",
                type:"get",
                dataType:"json",
                success: function (data) {
                    if(data.success){
                        window.location.href = "admin/login.jsp"
                    }else {
                        $.alert("注销失败")
                    }
                }
            })
        })
    })

</script>
<body style="background-color: #F7F8FA;">
<nav class="navbar navbar-default color" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" >BBS</a>
        </div>
        <div class="col-lg-6" style="width: auto;">
            <ul class="nav navbar-nav">
                <li><a href="admin/userList.jsp">用户管理</a></li>
                <li class="active"><a href="admin/getTopics.do">帖子管理</a></li>
            </ul>
        </div>
        <div class="col-lg-2 col-lg-offset-6">
            <ul class="nav navbar-nav">
                <li ><a  href="javascript:void(0)" class="logoutBtn" >注销</a></li>
            </ul>
        </div>
    </div>

</nav>


<div class="container-fluid content color main" style="width: 80%;">
    <div class="row">
        <div class="col-lg-12 ">
            <h2><span class="glyphicon glyphicon-list" aria-hidden="true"></span> 帖子管理 </h2>
            <hr>
        </div>
        <div class="container">
            <h3>帖子信息列表</h3>
            <form id="search" class="form-inline" action="" method="post">
                <div class="form-group">
                    <label for="exampleInputTitle2">标题</label>
                    <input type="text" name="title" value="" class="form-control" id="exampleInputTitle2">
                </div>
                <div class="form-group">
                    <label for="exampleInputName3">创建人</label>
                    <input type="text" name="name" value="" class="form-control" id="exampleInputName3">
                </div>
                <div class="form-group">
                    <label for="exampleInputTime2">创建时间</label>
                    <input type="text" name="time" value="" class="form-control" id="exampleInputTime2">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-default">查询</button>
                </div>
            </form>

            <div id="add_del">
                <a class="btn btn-primary" href="javascript:void(0);" >置顶选中</a>
                <a class="btn btn-primary" href="javascript:void(0);" >删除选中</a>
            </div>

            <form id="form" action="" method="post">
                <table border="1" class="table table-bordered table-hover">
                    <tr class="success">
                        <th><input type="checkbox" id="firstCb"></th>
                        <th>编号</th>
                        <th>标题</th>
                        <th>创建人</th>
                        <th>创建时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${topics}" var="topic" varStatus="s">
                        <tr>
                            <td><input type="checkbox" name="id" value="" class="content_Cb"></td>
                            <td>${s.count}</td>
                            <td>${topic.title}</td>
                            <td>${topic.createBy}</td>
                            <td>${topic.createTime}</td>
                            <td>${topic.status}</td>

                            <td>
                                <a class="btn btn-default btn-sm" href="admin/top.do?id=${topic.id}">置顶</a>&nbsp;
                                <a class="btn btn-default btn-sm" href="admin/essence.do?id=${topic.id}">加精</a>&nbsp;
                                <a class="btn btn-default btn-sm" href="admin/deleteTopicById.do?id=${topic.id}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                </table>
            </form>
        </div>
    </div>
</div>

<div class="modal-footer" style="margin-top: 10px">
    <div align="center"><a>Powered by 斌斌家豪涛顺 &nbsp;&nbsp;联系我们</a></div>
</div>
<script type="text/javascript">
</script>

</body>

</html>
